package com.cxrj.zhsq.utils;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: WangBo
 * @Description:
 * @Date: Create in 14:30 2017/11/27
 * @Modified By:
 */
public class MongoUtil {

    public static DBObject mapToDb(Map<String,Object> map){
        DBObject dbObject = new BasicDBObject();
        for (String k : map.keySet()){
            dbObject.put(k,map.get(k));
        }
        return dbObject;
    }

    public static Map<String,Object> DbToMap(DBObject dbObject){
        Map<String,Object> map = new HashMap<>();
        for (String k : dbObject.keySet()){
            map.put(k,dbObject.get(k));
        }
        return map;
    }
}
